#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int q = 0;
    cin >> q;
    while (q--)
    {
        int x = 0;
        cin >> x;
        string s = to_string(x);
        int i = 0;
        for (i = s.size() - 1;i >= 0;i--)
        {
            if (s[i] % 2 == 0)
            {
                swap(s[i], s[s.size() - 1]);
                cout << s << endl;
                break;
            }
        }
        if (i < 0)
        {
            cout << "-1" << endl;
        }
    }
    return 0;
}
